import {onMounted, ref} from 'vue'
import { useTableData } from "../../hooks/table/useTableData.js";
import { employeeMentDelete } from '../../api/employeeMent.js'
import { useConfirmAction } from '../../hooks/comfirm/useConfirmAction.js'
export function useEmployeeData () {
    const { confirm } = useConfirmAction()
    let columns = ref([
        {
            label: '员工名称',
            prop: 'name',
            align: 'center'
        },
        {

            label: '账号',
            prop: 'username',
            align: 'center'
        },
        {
            label: '手机号',
            prop: 'phone',
            align: 'center'
        },
        {
            label: '账号状态',
            prop: 'status',
            align: 'center',
            isSlot: true
        },
        {
            label: '操作',
            prop: 'general',
            align: 'center',
            isSlot: true,
        }

    ])
    const { sizeChange, prevClick, nextClick, currentChange, getTableData, tableData,total,loading } = useTableData('/employee/queryAll')
    onMounted(() => {
        getTableData().then(r => {})
    })
    async function deleteEmployee (row) {
        confirm('确定要删除这条数据吗？',async() => {
            await employeeMentDelete(row.id)
            await getTableData()
        }, () => {
            return false
        })
    }
    return {
        columns,
        tableData,
        sizeChange,
        currentChange,
        prevClick,
        nextClick,
        getTableData,
        deleteEmployee,
        total,
        loading
    }
}
